<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
    var i = 0;
    function ss(num){
        if (num == 1){
            console.log('num:'+ num + ',i: '+ ++i);
            return 1;
        } else {
            var r = num + ss(num-1);
            console.log('num:'+ num + ',i: '+ ++i);
            return r
        }

    }

    var a = ss(4)
</script>
</body>
</html>